import java.util.ArrayList;


public class MeanImage {
	private static final int numberOfRows = 28;
	private static final int numberOfColumns = 23;
	private double[][] meanImage;
	
	public MeanImage(ArrayList<TrainingImage> trainingImages){
		meanImage = _computeMeanImage(trainingImages);
	}

	private double[][] _computeMeanImage(ArrayList<TrainingImage> trainingImages) {
		double[][] meanImg = new double[numberOfRows][numberOfColumns];
		double meanValue = 0;
		for (int i = 0; i < numberOfRows; i++) {
			for (int j = 0; j < numberOfColumns; j++) {
				for (TrainingImage img : trainingImages) {
					meanValue += img.getLowFrequencyImage()[i][j];
				}
				meanImg[i][j] = (meanValue / (double)trainingImages.size());
				meanValue = 0;
			}
		}
		return meanImg;
	}
	
	public double[][] getMeanImage(){
		return this.meanImage;
	}
}
